<template>
    <div class="container">
            <div class="login-wrapper">
                <div class="header">Register</div>
                <div class="form-wrapper">
                    <input type="text" v-model="registerForm.username" placeholder="账户" class="input-item">
                    <input type="password" v-model="registerForm.password" placeholder="密码" class="input-item">
                    <input type="text" v-model="registerForm.nickName" placeholder="昵称" class="input-item">
                    <div class="btn" @click="handleRegister()">Register</div>
                </div>
            </div>
        </div>
</template>
    
<script setup name="Reg">
import { reactive } from 'vue';
import axios from 'axios';
import { ElMessage } from 'element-plus';
import { useRouter } from 'vue-router';

const router= useRouter()

const registerForm = reactive({
    username: '',
    password: '',
    nickName: ''
})

const handleRegister = () => {
    axios.post("/api/api/user/register", registerForm).then(res => {
        if(res.data.code==200){
            ElMessage.success('Register success')
            router.push('/login')
        }
    })
}
</script>

<style scoped>
html {
    height: 100%;
}
body {
    height: 100%;
}
.container {
    /* margin-top: 5%; */
    height: 100vh;
    width: 100%;
    background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
}
.login-wrapper {
    background-color: #fff;
    width: 358px;
    height: 588px;
    border-radius: 15px;
    padding: 0 50px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
.header {
    font-size: 38px;
    font-weight: bold;
    text-align: center;
    line-height: 200px;
}
.input-item {
    display: block;
    width: 100%;
    margin-bottom: 20px;
    border: 0;
    padding: 10px;
    border-bottom: 1px solid rgb(128, 125, 125);
    font-size: 15px;
    outline: none;
}
.input-item:placeholder {
    text-transform: uppercase;
}
.btn {
    text-align: center;
    padding: 10px;
    width: 100%;
    margin-top: 40px;
    background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
    color: #fff;
    margin: 0 auto;
    cursor: pointer;
}
.msg {
    text-align: center;
    line-height: 88px;
}
a {
    text-decoration-line: none;
    color: #abc1ee;
}

</style>